public class maxArea {
    public int maxArea(int[] height) {
        int i = 0;
        int j = height.length-1;
        int max = 0;
        while(j > i){
            int area = Math.min(height[i], height[j]) * (j-i);
            max = Math.max(max,area);
            if(height[i] <= height[j]){
                i++;
            }else{
                j--;
            }
        }
        return max;
    }
}
